<?php
defined('IN_XLP') or exit('Access Denied');
$Document = array(
    'pageid'   => 'goods-add', //页面标示
    'pagename' => '新增产品', //当前页面名称
    'mycss'    => array('../jquery-ui/css/smoothness/jquery-ui-1.10.0.custom.min','content/webuploader'), //加载的css样式表
    'myjs'     => array('content/jquery.smoothConfirm'), //加载的js脚本
    'footerjs' => array('content/fuelux/fuelux', 'content/combodate/moment.min', '../jquery-ui/js/jquery-ui-1.10.0.custom.min'),
    'head'     => true, //加载头部文件
);
include getTpl('header', 'public');
?>
<style>
.w80{width:80px;text-align:center;}
.hide{display:none;}
</style>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
  <section id="content">
    <section class="main padder"> 
    <div class="clearfix"> 
     <h4><i class="fa fa-edit"></i>新增产品</h4> 
    </div> 
    <div class="row"> 
     <div class="col-sm-12"> 
      <section class="panel"> 
       <div class="panel-body"> 
        <form class="form-horizontal" id="goodsAddForm" method="post" > 
         <div class="form-group"> 
          <label class="col-sm-1 control-label">名称</label> 
          <div class="col-sm-2"> 
            <input type="text" name="goods_name" id="goods_name" placeholder="产品名称" class="form-control" data-required="true"  />
          </div> 
         </div> 
         
        <div class="form-group"> 
          <label class="col-sm-1 control-label">所属类型</label> 
          <div class="col-sm-2">
            <select name="cid" id="cid" class="form-control">
              <option value="0">选择所属类型</option>
              <?php echo $goods_cate; ?>
            </select>
          </div> 
        </div>

       <div class="form-group"> 
          <label class="col-sm-1 control-label">预计年化收益率</label> 
          <div class="col-sm-2"> 
            <input type="text" name="goods_tips" id="goods_tips" placeholder="10%" class="form-control" data-required="true" />
          </div> 
         </div>
        
         <style>.row .checkbox{float:left}</style>

         <div class="form-group"> 
          <label class="col-sm-1 control-label">是否上架</label>
            <div class="row">
              <div class="col-xs-1 radio m-l-large"><label class="radio-custom"> <input type="radio" name="state" checked="checked" value="1" /> <i class="fa fa-circle-o"></i>上架</label></div>
              <div class="col-xs-1 radio m-l-large"><label class="radio-custom"> <input type="radio" name="state" value="2" /> <i class="fa fa-circle-o"></i>下架</label></div>
            </div>
         </div>

         <div class="form-group"> 
          <div class="col-sm-9 col-lg-offset-1"> 
            <span id="goodsImage"></span>
            <div class="col-sm-1"><button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button></div>
            <button type="button" class="btn btn-white col-md-offset-1">取消</button> 
          </div> 
         </div> 
        </form> 
       </div> 
      </section>
     </div> 
    </div> 
   </section> 

  </section> 
  <!--/ content --> 
<!--主体 结束-->
<style type="text/css">
  .removeFile{float:left;margin:115px 0 20px -85px;cursor: pointer;color: #5191d1;}
</style>
<script>    
$(function(){

  $('#goodsAddForm').submit(function(){
    if (!$('#goods_name').val()){
      Msg.error('请输入产品名称');
      resetSubmit("#sub-ok",'提交');
      return false;
    }

    
    if ($('#cid').val() == 0){
      Msg.error('请选择所属产品类型');
      resetSubmit("#sub-ok",'提交');
      return false;
    }

    if (!$('#goods_tips').val()){
      Msg.error('请输入年化收益率');
      resetSubmit("#sub-ok",'提交');
      return false;
    }

    Msg.loading();
    $.post('<?php echo U('goods/add');?>',$(this).serialize(),function(result){
      Msg.hide();
      resetSubmit("#sub-ok",'提交');
      if (result.status==1){
        self.location.href = '<?php echo U("content/goods/index"); ?>';
      }else{
        Msg.error(result.info);
      }
    },'json');
    return false;
  });
})
</script>
<?php include getTpl('footer', 'public'); ?>